#{extends 'main.html' /} #{set title:'Make Contributor' /}
<!-- @author Ebaa

this page displays all the created tutorials of the user with a button beside each to make a user contributor to a tutorial -->
<br></br><B>Choosen member to be a contributor is  ${models.RegisteredUser.findById(userId).name}</B>
#{ifnot tuts}
<p>You have no created tutorials</p>
#{/ifnot} #{list items:tuts, as:'tutorial'}
<li>
	<p>${tutorial.Title}</p> <script type="text/javascript">
		function confirmation() {
			var answer = confirm("Are you sure you want to make this member a contributor?")
			if (answer) {
				alert("This member is now a contributor to the selected tutorial")
				return true
			} else {
				return false
			}
		}
	</script> 
	#{if !(models.RegisteredUser.findById(userId).getContributedTutorials().contains(tutorial))}
	<form action="@{CommunityLists.makeContributorToTut()}" method="GET">
		<div id="${tutorial.id}">
			<button name="tutId" type="submit" value="${tutorial.id}"
				onClick="return confirmation()">Make Contributor to this
				tutorial</button>
			<input type="hidden" name="userId" value="${userId}" />
		</div>
	</form> #{/if} #{else} Already Contributor to this tutorial #{/else}
</li>
#{/list}
